package org.dromara.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.system.domain.XfCompanyDimensionStatistics;
import org.dromara.system.domain.query.XfCompanyDimensionStatisticsQuery;
import org.dromara.system.domain.vo.XfCompanyDimensionStatisticsVo;
import org.dromara.system.mapper.XfCompanyDimensionStatisticsMapper;
import org.dromara.system.service.IXfCompanyDimensionStatisticsService;
import org.springframework.stereotype.Service;

import java.util.List;

@RequiredArgsConstructor
@Service
public class XfCompanyDimensionStatisticsServiceImpl implements IXfCompanyDimensionStatisticsService {
    
    private final XfCompanyDimensionStatisticsMapper xfCompanyDimensionStatisticsMapper;

    @Override
    public List<XfCompanyDimensionStatisticsVo> queryList(XfCompanyDimensionStatisticsQuery query) {
        return xfCompanyDimensionStatisticsMapper.queryList(query);
    }

    @Override
    public TableDataInfo<XfCompanyDimensionStatisticsVo> queryPageList(XfCompanyDimensionStatisticsQuery query, PageQuery pageQuery) {
        LambdaQueryWrapper<XfCompanyDimensionStatistics> lqw = Wrappers.lambdaQuery();
        lqw.eq(query.getCompanyId() != null, XfCompanyDimensionStatistics::getCompanyId, query.getCompanyId());
        lqw.eq(query.getDimensionId() != null, XfCompanyDimensionStatistics::getDimensionId, query.getDimensionId());
        Page<XfCompanyDimensionStatisticsVo> page = xfCompanyDimensionStatisticsMapper.selectPageXfCompanyDimensionStatisticsList(pageQuery.build(), lqw);
        return TableDataInfo.build(page);
    }
}